#!/usr/bin/env python
# coding=utf-8
"""
# @Created on : 2016/04/21 6:27
# @Author     : ldf (ldf@eehello.com)
# @Link       : http://www.eehello.com
# @Version    : 
# 本程序在python2.7下测试通过
"""

import socket

def handle_request(client):
    buf = client.recv(1024)
    client.send("HTTP/1.1 200 OK\r\n\r\n")
    client.send("Hello, ldf\n")
    client.send("Hello, ee\n")
    with open('yanshi.txt','rb') as fy:
        client.send(fy.read())

    with open('123.txt','rb') as fy:
        client.send(fy.read())

def main():
    sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM,0)
    sock.bind(('localhost',8080))
    sock.listen(5)

    while True:
        connection, address = sock.accept()
        handle_request(connection)
        connection.close()

if __name__ == '__main__':
    main()

